<?php
namespace app\index\controller;

use app\common\controller\HomeBase;
use app\common\model\Jumpcategory as CategoryModel;
use app\common\model\JumpImg as JumpImgModel;
use think\Session;

class JumpImg extends HomeBase
{
    protected $jump_img_model;

    public function _initialize(){
        parent::_initialize();
        $this->category_model = new CategoryModel();
        $this->jump_img_model = new JumpImgModel();
        $category_level_list  = $this->category_model->getLevelList();
        $erji = $this->category_model->where('pid','neq','0')->select();
        $this->assign('erjicategory_level_list', $erji);
        $this->assign('imgcategory_level_list', $category_level_list);
        $this->assign('title','一跳三跳列表');
    }

    public function index(){
        $result = $this->jump_img_model
                    ->order('id desc')
                    ->select();
        $this->assign('img_list',$result);
        return $this->fetch();
    }

    public function img_detail($id){
        $index_id = session::get('index_id');
        if($index_id){
            $list = $this->jump_img_model->where('pid',$id)->column('path,title');
        }else{
            $list = $this->jump_img_model->where('pid',$id)->column('thumb,title');
            // dump($list);exit();
        }
        $this->assign('list',$list);
        return $this->fetch();
    }
    public function index_bk(){
        $result = $this->jump_img_model
            ->order('id desc')
            ->select();
        $this->assign('img_list',$result);
        return $this->fetch();
    }

}